﻿using System;
using System.Collections.Generic;
using System.Text;

namespace daSyntaxAnalyser.SyntaxTree
{
    using daBase.Objects;

    public class ArrayIndexElement : BlockOfPartOfStandartVariableExpressionElement
    {
        private List<ExpressionElement> expressions;

        public List<ExpressionElement> Expressions { get { return expressions; } set { expressions = value; } }

        public ArrayIndexElement(TokenInfo StartInfo, List<ExpressionElement> Expressions, List<TokenInfo> Comments)
            : base(StartInfo, Comments)
        {
            expressions = Expressions;
        }

        public override string ToString()
        {
            string result = string.Empty;
            if (expressions != null)
                result = expressions.Join(", ");
            return string.Format("[{0}]", result);
        }

        protected override IEnumerator<ISyntaxTreeElement> CreateEnumerator()
        {
            foreach (ExpressionElement expression in expressions)
                yield return expression;
        }
    }
}
